<%# locals: (new_message:, replying:) -%>
<%= form_with model: new_message, url: new_message, method: :post do |f| %>
  <%= errors_for new_message %>

  <div class="labelled_grid">
    <% if replying %>
        <%= f.hidden_field :recipient_username  %>
    <% else %>
      <%= f.label :recipient_username, "To", :class => "required" %>
      <%= f.text_field :recipient_username %>
    <% end %>

    <%= f.label :subject, "Subject", :class => "required" %>
    <%= f.text_field :subject, :maxlength => 100 %>

    <%= f.label :body, "Message", :class => "required" %>
    <%= f.text_area :body, :rows => 5 %>

    <% if @user.wearable_hats.load.any? %>
      <%= f.label :hat_id, 'Put on hat' %>
      <%= f.select :hat_id, options_for_select( [['','']] +
        @user.wearable_hats.map{|h| [h.hat, { 'data-modnote' => h.modlog_use }, h.short_id] }
      ) %>
      <% if @user.is_moderator? %>
        <%= f.label :mod_note, 'ModNote', class: 'normal for_checkbox' %>
        <%= f.check_box 'mod_note', class: 'normal' %>
      <% end %>
    <% end %>
  </div>

  <%= f.submit replying ? "Reply" : "Send Message" %>
<% end %>
